
export  class Team {
  name:string;
  createTime:number;
  endTime:number;
  administrator:string;
  adminGuid:string;
  teamGuid:string;
  appArr:Array<object>=[];
  packageArr:Array<any> = [];//二维数组，存储教案包母本以及副本
  status:number;
  isEdit:boolean = false;
  isPackageEdit:Array<boolean>= [];//每个教案包需要一个变量来控制
  isAdmin:boolean =false;
  isModifyTeamName:boolean =false;
  haveAccreditMembers:Array<object>=[];
  noAccreditMembers:Array<object>=[];
  memberWidth: number=78;//每一个团队人所占的宽度，加上margin
  isLimitHeight:boolean = false;
  isTransform:boolean = false;//是否旋转按钮
  openAdminSeeting:boolean =false;//是否打开团队设置
  openAccredit:boolean = false;//是否打开团队授权
  isDated:boolean;//当前团队是否过期
  Cover:string;//管理员头像地址
  duplicates:Array<any> = []; //二维数组，单独存放每个教案包的副本
  showMoreDuplicate:Array<boolean> = [];//存放控制是否显示更多的副本的那个按钮
  limitNumber:number;
  constructor (name:string,createTime:number,endTime:number,administrator:string,teamGuid:string,status:number,adminGuid:string,limitNumber:number) {
    let nowTime = Number(((new Date()).getTime()/1000).toFixed(0));//获取当前时间
    this.name = name;
    this.createTime =createTime;
    this.endTime =endTime;
    this.administrator = administrator;
    this.teamGuid = teamGuid;
    this.status = status;
    this.adminGuid = adminGuid;
    this.limitNumber =limitNumber;
    if(nowTime>this.endTime){
      this.isDated = true;
    }
  };
  limitHeight(membersWidth){
    let currentHeight;
    currentHeight =(this.haveAccreditMembers.length +1) * this.memberWidth;
    if(currentHeight>membersWidth){
      this.isLimitHeight = true;
    }else {
      this.isLimitHeight = false;
    }
  }
  getTeamApp(app) {
    this.appArr.push(app);
  }
  initDuplicate(){
    this.packageArr.forEach((packetArr,index)=>{
      this.isPackageEdit[index]=false;  //初始化每个教案包的编辑控制
      this.duplicates[index] = [];
      if(packetArr.length>1){
          //存在副本的情况
          this.duplicates[index] = packetArr.slice(1);
        }
    })
  }
  //计算总共能容纳个副本
  contTotalDuplicate(clientWidth,duplicateWidth){
      let cotaninerWidth = clientWidth*0.8*0.65;
      let total =Math.floor(cotaninerWidth/duplicateWidth)*2-1;
      //总共有2列，再一个logo
      this.initShowMoreDuplicate(total);
      return total;
  }
  //初始化控制显示更多副本按钮
  initShowMoreDuplicate(total){
     this.duplicates.forEach((duplicates,index)=>{
          if(duplicates.length>total){
            this.showMoreDuplicate[index]=true;
          }else{
            this.showMoreDuplicate[index]=false;
          }
     });
  }
 //根据副本的guid以及教案包的索引删除副本
  deleteDuplicate(index,packetGuid){
    for(let i=0;i<this.duplicates[index].length;i++){
      if(this.duplicates[index][i].packetGuid ==packetGuid ){
        this.duplicates[index].splice(i,1);
        return;
      }
    }
  }
}
